package com.codepilot.server.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.codepilot.server.service.AuthenticateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.codepilot.server.model.vo.CommonResult;
import com.codepilot.server.model.vo.LoginUserVO;
import com.codepilot.server.model.vo.RegisterUserVO;

@RestController
@RequestMapping("/api/user/authenticate")
@Api(tags = "用户注册、登录接口")
public class AuthenticateController {

    @Autowired
    private AuthenticateService authenticateService;

    @PostMapping("/register")
    @ApiOperation("用户注册")
    public CommonResult<?> register(@RequestBody RegisterUserVO registerUserVO) {
        return authenticateService.register(registerUserVO);
    }

    @PostMapping("/login")
    @ApiOperation("用户登录")
    public CommonResult<?> login(@RequestBody LoginUserVO loginUserVO) {
        return authenticateService.login(loginUserVO);
    }

}
